﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace CrazySname.GameClasses
{
    public class Utilitarios
    {
        public static int Const = 16;

        public bool ChecaIntersecao(Vector2 posicao1, Vector2 posicao2)
        {
            bool c = posicao1.Y > posicao2.Y - Const && posicao1.Y < posicao2.Y + Const;
            bool e = posicao1.X > posicao2.X - Const && posicao1.X < posicao2.X + Const;
            return (c && e);
        }


    }

    static class PixelCollision
    {
        static public bool Intersects(this Point vec,Texture2D texture, Rectangle frame, byte alpha)
        {

            if ((vec.X >= frame.X && vec.X < frame.Right) && (vec.Y >= frame.Y && vec.Y < frame.Bottom))
            {

                Color[] data = new Color[1];

                texture.GetData(0, new Rectangle(vec.X - frame.X, vec.Y - frame.Y, 1, 1), data, 0, 1);

                if (data[0].A >= alpha) return true;

            }

            return false;
        }
    }
}